package de.wesemann.mediahandbook.le.activity.helper;

import android.app.Dialog;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import de.wesemann.mediahandbook.le.R;
import de.wesemann.mediahandbook.le.activity.MediahandbookLe;

public abstract class AbstractListActivity extends ListActivity implements ActivityHelper {
	private static final String LOG_TAG = AbstractListActivity.class.getSimpleName();

	protected static final int LOADING_DIALOG = 0;
	public boolean mShownDialog;

	protected Dialog onCreateDialog(int id) {
		Log.d(LOG_TAG, "onCreateDialog " + id);
		if (id == LOADING_DIALOG) {
			Log.d(LOG_TAG, "The Id is the Id " + id);
			ProgressDialog loadingDialog = new ProgressDialog(this);
			loadingDialog.setMessage(getString(R.string.please_wait));
			// loadingDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
			loadingDialog.setCancelable(false);
			return loadingDialog;
		}
		return super.onCreateDialog(id);
	}

	/**
	 * Here, we're maintaining the mShownDialog flag in the activity so that it
	 * knows that the progress dialog has been shown. The flag is required when
	 * dismissing the dialog, as the only activity that is allowed to dismiss
	 * the dialog is the activity that has also created it.
	 */
	@Override
	protected void onPrepareDialog(int id, Dialog dialog) {
		super.onPrepareDialog(id, dialog);
		Log.d(LOG_TAG, "onPrepareDialog() " + id);
		if (id == LOADING_DIALOG) {
			Log.d(LOG_TAG, "turn on showDialog");
			mShownDialog = true;
		}
	}

	public void onImageClick(View view) {
		if (view.getId() == R.id.title_icon) {
//			Toast.makeText(this, "revert clicked", Toast.LENGTH_SHORT).show();
			Intent intent = new Intent(this, MediahandbookLe.class);
			startActivity(intent);
			finish();
		}

	}


}
